<%= link_to_function("Add", :id => "link_player_#{home_away}") do |page|
  page["link_player_#{home_away}"].hide
  page["add_player_#{home_away}"].show
  page["#{home_away}_player_name"].activate
end %>
<div id="add_player_<%= home_away %>" style="display: none">
  <%= text_field_tag "#{home_away}_player_name", "", :onkeypress => "return ignoreEnter(event)", :size => 10 %><br/>
  <%= button_to_function "Cancel" do |page| 
        page["link_player_#{home_away}"].show
        page["add_player_#{home_away}"].hide
      end %>
  <%= button_to_function "New", remote_function(
          :url => { :action => :insert_team_player, :id => game,
                    "team_player[championship_id]"=> game.phase.championship.id,
                    "team_player[team_id]" => team.id,
                    "home_away" => home_away,
                    "partial" => partial },
          :confirm => "Are you sure you want to create a new player?",
          :with => "'name='+$(#{home_away}_player_name).value",
          :complete => "finishPlayerAdd('#{home_away}')",
          :failure => "alert('Could not insert player')") %>
  <%= observe_field "#{home_away}_player_name",
    :frequency => 1,
    :url => { :action => :list_players,
              :team => team,
              :game => game,
              :partial => partial },
    :with => "name"
    %>
  <div id="<%= home_away %>_add_player_list">
  </div>
</div>
